package com.xiaoc.bulldozer.common.service.impl;

import java.text.DateFormat;
import java.util.List;
import java.util.Date;
import javax.annotation.Resource;

import com.xiaoc.bulldozer.common.util.ThreadLocalUtil;
import org.springframework.stereotype.Service;
import com.xiaoc.bulldozer.common.dao.AwardTimeRuleMapper;
import com.xiaoc.bulldozer.common.dto.AwardTimeRuleQueryDto;
import com.xiaoc.bulldozer.common.model.AwardTimeRule;
import com.xiaoc.bulldozer.common.service.AwardTimeRuleService;

/**
 * AwardTimeRule Service 实现类
 * 
 * @author Danfo Yam
 * 
 * @date 2018-12-24 10:00:41
 */
@Service("awardTimeRuleService")
public class AwardTimeRuleServiceImpl implements AwardTimeRuleService {

    @Resource
    private AwardTimeRuleMapper awardTimeRuleMapper;

    @Override
    public Integer getAwardTimeRuleCountByCondition(AwardTimeRuleQueryDto awardTimeRuleQueryDto) {
        return awardTimeRuleMapper.getAwardTimeRuleCountByCondition(awardTimeRuleQueryDto);
    }

    @Override
    public List<AwardTimeRule> getAwardTimeRuleListByCondition(AwardTimeRuleQueryDto awardTimeRuleQueryDto) {
        return awardTimeRuleMapper.getAwardTimeRuleListByCondition(awardTimeRuleQueryDto);
    }

    @Override
    public AwardTimeRule getAwardTimeRuleById(Integer id) {
        return awardTimeRuleMapper.getAwardTimeRuleById(id);
    }

    @Override
    public List<AwardTimeRule> getAllAwardTimeRuleList() {
        return awardTimeRuleMapper.getAllAwardTimeRuleList();
    }
    
    @Override
    public void save(AwardTimeRule awardTimeRule) {
        awardTimeRuleMapper.save(awardTimeRule);
    }

    @Override
    public void update(AwardTimeRule awardTimeRule) {
        awardTimeRuleMapper.update(awardTimeRule);
    }

    @Override
    public void deleteById(Integer id) {
        awardTimeRuleMapper.deleteById(id);
    }


    @Override
    public AwardTimeRule getAwardTimeRuleByCurrentTime(String currentTime) {
        return awardTimeRuleMapper.getAwardTimeRuleByCurrentTime(currentTime);
    }

    @Override
    public AwardTimeRule getNextAwardTimeRuleByCurrentTime(String currentTime) {
        return awardTimeRuleMapper.getNextAwardTimeRuleByCurrentTime(currentTime);
    }

    @Override
    public AwardTimeRule getAwardTimeRuleByCurrentTime1() {
        DateFormat dateFormat = ThreadLocalUtil.getDateFormat("yyyy-MM-dd HH:mm:ss");
        Date currentDate = new Date();
        String currentTimeStr = dateFormat.format(currentDate);
        return awardTimeRuleMapper.getAwardTimeRuleByCurrentTime1(currentTimeStr);
    }
}
